package com.chenyun.common.vo;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.annotation.JSONField;
import com.chenyun.common.enums.LoginDeviceTypeEnum;
import com.chenyun.common.enums.LoginUserTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Map;

/**
 * LoginVO：
 * Description:
 *
 * @author: Lonni
 * @date: 2022/8/18 0018 10:29
 */

@Data
@ApiModel("登录实体类")
public class LoginVO {
    // 无用参数开始
    @ApiModelProperty(name = "grantType",value = "授权模式,在使用oauth2方式登录时才传入;,扩展 mobile|| captcha||wechat ")
    @JSONField(name = "grant_type")
    private String grantType;
    @ApiModelProperty(name = "clientId",value = "Oauth2客户端ID;在使用oauth2方式登录时才传入; ")
    @JSONField(name = "client_id")
    private String clientId;
    @ApiModelProperty(name = "clientSecret",value = "Oauth2客户端秘钥;在使用oauth2方式登录时才传入; ")
    @JSONField(name = "client_secret")
    private String clientSecret;
    @ApiModelProperty(name = "refresToken",value = "刷新token;登录不需要 ")
    @JSONField(name = "refresh_token")
    private String refresToken;
    // 无用参数结束


    @ApiModelProperty(name = "username",value = "用户名 ")
    private String username;
    @ApiModelProperty(name = "password",value = "密码 ")
    private String password;
    @ApiModelProperty(name = "userType",value = "登录用户类型 admin:管理相关用户登录 business:商家登录/卖家登录;member:买家||会员   ")
    private LoginUserTypeEnum userType;
    @ApiModelProperty(name = "deviceType",value = "登录设备类型;  pc  | app | mp:小程序")
    private LoginDeviceTypeEnum deviceType;
    @ApiModelProperty(name = "code",value = "小程序code/或者短信code /验证码code ")
    private String code;
    @ApiModelProperty(name = "phone",value = "手机号 ")
    private String phone;

    @ApiModelProperty(name = "jsCode",value = "调用wx.login获取的code,用于获取openId;小程序必填 ")
    private String jsCode;
    @ApiModelProperty(name = "phoneCode",value = "调用wx.getPhoneNumber获取的code,用于解密手机号;小程序必填 ")
    private String phoneCode;
    @ApiModelProperty(name = "appId",value = "小程序的appid;小程序必填")
    private String appId;


    @ApiModelProperty(name = "uuid", value = "图片验证码模式需要传入uuid标识")
    private String uuid;



    /**
     * 将当前类转换为oauth2使用的map类型
     * @return
     */
    public Map<String, String> convertVoToMapOfOauth2(){
        LoginVO vo=this;
        String jsonString = JSON.toJSONString(vo);
        Map map = JSON.parseObject(jsonString, Map.class);
        return map;
    }



}
